import org.apache.spark.{SparkConf, SparkContext}

object Spark_Test {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setAppName("aaa").setMaster("local[*]")

    val sc = new SparkContext(conf)

    val lineRDD = sc.textFile("D:\\IdeaProjects\\maven_test\\input\\1.txt")

    val wordRDD = lineRDD.flatMap(_.split(" "))

    val word2oneRDD = wordRDD.map((_, 1))

    val reduceRDD = word2oneRDD.reduceByKey(_ + _)

    reduceRDD.foreach(println)

    sc.stop()
  }

}
